class Solution1 {
    public int longestOnes(int[] nums, int k) {
        int sum = 0 ;
        int count = 0 ;
        for(int i = 0 ,j=0 ; j < nums.length ; j ++){
            //进窗口
            if(nums[j] == 0){
                count ++ ;
            }
            //出窗口
            while(count > k){
                if(nums[i++] == 0){
                    count --;
                }
            }
            //更新结果
            sum = Math.max(sum , j-i+1);
        }
        return sum ;

    }
}